package cn.dengta.webapp.base.entity;

import cn.dengta.common.context.Env;
import cn.dengta.common.model.ValueProxy;
import cn.dengta.common.model.ValueProxyImpl;
import lombok.Getter;

@Getter
public enum ChannelName implements ValueProxyImpl<ChannelName, String> {

	/** main */
	main("main", "com.qs.flala", "com.sheyu.fla", "com.dev.liaoyu"),

	//
	;

	// 定义私有变量
	public final String androidPackage;
	public final String iosPackage;
	public final String testIospackage;
	final ValueProxy<ChannelName, String> proxy;

	// 构造函数，枚举类型只能为私有
	ChannelName(String label, String androidPackage, String iosPackage, String testIospackage) {
		this.androidPackage = androidPackage;
		this.iosPackage = iosPackage;
		this.testIospackage = testIospackage;
		this.proxy = new ValueProxy<>(this, name(), label);
	}

	public String findIosPackage() {
		return Env.inProduction() ? this.iosPackage : testIospackage;
	}

	public static ChannelName[] getValues() {
		return ValueProxy.getCachedArray(ChannelName.class, ChannelName::values);
	}

	public static ChannelName of(String value) {
		return main.getValueOf(value);
	}

	public static ChannelName ofOrDefault(String value) {
		ChannelName channel = of(value);
		return channel == null ? main : channel;
	}

}
